package com.eas.biz.service.statistic.domain;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.eas.biz.service.exam.domain.Exam;

public class BaseExamStatistic {

    private long examId;

    private float avgScore;

    private float maxScore;

    private float minScore;

    private int studentCount;

    private double standardDiviation;

    private Exam examInfo;

    protected List<GradeLevelCount> gradeList;

    protected Map<String, GradeLevelCount> levelMap;

    public BaseExamStatistic() {
        gradeList = new LinkedList<GradeLevelCount>();
        levelMap = new HashMap<String, GradeLevelCount>();
    }

    public void addGradeCount(GradeLevelCount count) {
        if (count != null) {
            gradeList.add(count);
        }
    }

    public long getExamId() {
        return examId;
    }

    public void setExamId(long examId) {
        this.examId = examId;
    }

    public List<GradeLevelCount> getGradeList() {
        return gradeList;
    }

    public float getAvgScore() {
        return avgScore;
    }

    public void setAvgScore(float avgScore) {
        this.avgScore = avgScore;
    }

    public float getMaxScore() {
        return maxScore;
    }

    public void setMaxScore(float maxScore) {
        this.maxScore = maxScore;
    }

    public float getMinScore() {
        return minScore;
    }

    public void setMinScore(float minScore) {
        this.minScore = minScore;
    }

    public void setGradeList(List<GradeLevelCount> gradeList) {
        this.gradeList = gradeList;
        this.buildLevelMap();
    }

    public Exam getExamInfo() {
        return examInfo;
    }

    public void setExamInfo(Exam examInfo) {
        this.examInfo = examInfo;
    }

    public void buildLevelMap() {
        levelMap.clear();
        for (GradeLevelCount gradeLevel : gradeList) {
            levelMap.put(gradeLevel.getLevel(), gradeLevel);
        }
    }

    public Map<String, GradeLevelCount> getLevelMap() {
        return levelMap;
    }

    public void setLevelMap(Map<String, GradeLevelCount> levelMap) {
        this.levelMap = levelMap;
    }

    public int getStudentCount() {
        return studentCount;
    }

    public void setStudentCount(int studentCount) {
        this.studentCount = studentCount;
    }

    public double getStandardDiviation() {
        return standardDiviation;
    }

    public void setStandardDiviation(double standardDiviation) {
        this.standardDiviation = standardDiviation;
    }

}
